<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            name: 'zs',
            age: 3,
            say: 'wow',
            ha: 'hahaha'
        }
        // obj[Symbol.iterator] =
         function iter(obj) {
            let keyArr = Object.keys(obj);
            let index = 0;
            return {
                next() {
                    index++
                    return index < keyArr.length ? {
                        value: {
                            key: keyArr[index-1],
                            val: obj[keyArr[index-1]],
                            index,
                            'done':false
                        },
                    }:{
                        'done': true
                    }
                }
            }
        }
        let iterator = iter(obj)
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        // for(let key of obj){
        //     console.log(key);
        // }
    </script>
</body>

</html>